/*
 * @Author: 颜礼田 2564217790@qq.com
 * @Date: 2024-09-06 18:22:28
 * @LastEditors: MrDotYan 2564217790@qq.com
 * @LastEditTime: 2024-09-19 16:03:35
 * @FilePath: /webServer/src/config/config.default.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { MidwayConfig } from '@midwayjs/core';
import { join } from 'path';

export default {
  keys: '1725618148089_478_default',
  /**服务端口/api前缀配置 */
  koa: {
    port: 7001,
    globalPrefix: '/web-server-api',
  },
  /** socket配置 */
  socketIO: {
    cors: {
      origin: '*',
    },
  },
  /**
   * 无需访问检查的接口
   */
  iForbidderRoute: ['/web-server-api/'],
  /**
   * 无需登录鉴权的接口
   **/
  iRoute: ['/web-server-api/', '/web-server-api/auth/login'],
  /**
   *接口文档配置*/
  swagger: {
    title: 'MA-WebServer',
    auth: {
      authType: 'bearer',
    },
  },
  /** 邮件组件配置 */
  mailer: {
    host: 'smtp.sina.com', //163、qq等
    secureConnection: true,
    prefix: '【MA】', //邮件前缀
    secure: true,
    auth: {
      user: 'yncykj@sina.com', //邮箱
      pass: '5bb7395f4130f589', //邮箱密码或授权码
    },
    tls: {
      rejectUnauthorized: true,
      minVersion: 'TLSv1.2',
    },
  },
  /** 验证码配置 */
  captcha: {
    expirationTime: 5 * 60,
  },
  /** 鉴权策略配置 */
  passport: {
    session: false,
  },
  /** 参数校验配置 */
  validate: {
    validationOptions: {
      stripUnknown: true, // 全局生效
    },
  },
  /** json web toekn 配置 */
  jwt: {
    algorithm: 'HS512',
    secret: 'keys_1723454400165_5627_default',
    expiresIn: '30d',
  },
  /** 文件上传配置 */
  busboy: {
    mode: 'file',
    tmpdir: join(__dirname, '../../', 'uploads'),
    cleanTimeout: 0,
  },
  /** 静态文件托管 */
  staticFile: {
    dirs: {
      default: {
        prefix: '/',
        dir: 'public',
      },
      uploads: {
        prefix: '/uploads',
        dir: 'uploads',
      },
      merger: {
        prefix: '/merge',
        dir: 'merge',
      },
    },
  },
  /** 日志目录配置 */
  midwayLogger: {
    default: {
      dir: 'logger',
    },
  },
  /** 安全策略配置 */
  security: {
    csrf: {
      enable: false,
      type: 'ctoken',
      useSession: false,
      cookieName: 'csrfToken',
      sessionName: 'csrfToken',
      headerName: 'x-csrf-token',
      bodyName: '_csrf',
      queryName: '_csrf',
      refererWhiteList: [],
    },
    xframe: {
      enable: true,
      value: 'SAMEORIGIN',
    },
    csp: {
      enable: false,
    },
    hsts: {
      enable: false,
      maxAge: 365 * 24 * 3600,
      includeSubdomains: false,
    },
    noopen: {
      enable: false,
    },
    nosniff: {
      enable: false,
    },
    xssProtection: {
      enable: true,
      value: '1; mode=block',
    },
  },
} as MidwayConfig;
